package com.example.web.controller;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.web.entity.Order;
import com.example.web.entity.User;
import com.example.web.tool.Result;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;

@Api(description = "订单管理", tags = "订单操作接口")
@RestController
@Slf4j
public class OrderController {

	@ApiOperation(value = "存订单", notes = "提交xxx数据")
	@ApiImplicitParam(name = "order", value = "订单对象", dataType = "Order")
	@PostMapping("/order")
	public Result<Order> save(Order order) {
		return Result.build(1, "success", order);
	}

	@ApiOperation(value="查询订单",notes="根据{number:订单编号}查询")
	@ApiImplicitParam(name="number",value="订单编号",dataType="String",paramType="path")
	@GetMapping("/order/{number}")
	public Result<Order> getOrder(@PathVariable("number") String number){
		log.info("number:{}",number);
		Order o = new Order();
		o.setAmount("123");
		o.setNumber(number);
		o.setProduct("xxx");
		User u = new User();
		u.setAge("18");
		u.setCup("36D");
		u.setEmail("xxxx@qq.com");
		u.setName("Mary");
		u.setPassword("xxxxx");
		u.setSex("girl");
		o.setUser(u);
		return Result.build(1, "success",o);
	}
	
}
